//
//  XLCIViewResourcesManager.m
//
//  Created by ilongge on 2022/7/26.
//

#import "XLCIViewResourcesManager.h"

static dispatch_once_t _onceToken;
static NSBundle *_resourcesBundle = nil;

@implementation XLCIViewResourcesManager

+ (NSBundle *)XLCIResourcesBundle
{
    if (_resourcesBundle == nil) {
        NSBundle *currrentBundle = [NSBundle bundleForClass:[XLCIViewResourcesManager class]];
        NSString *buntdlePath = [currrentBundle pathForResource:@"XLConversationInputView" ofType:@"bundle"];
        NSBundle *bundle = [NSBundle bundleWithPath:buntdlePath];
        dispatch_once(&_onceToken, ^{
            _resourcesBundle = bundle;
        });
    }
    return _resourcesBundle;
}

+ (UIImage *)imageNamed:(NSString *)name {
    if (name.length) {
        NSBundle *bundle = [XLCIViewResourcesManager XLCIResourcesBundle];
        UIImage *image = [UIImage imageNamed:name
                                    inBundle:bundle
               compatibleWithTraitCollection:nil];
        return image;
    }
    return nil;
}
@end
